<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>配置方案信息</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../elementUI/index.css">
    <link rel="stylesheet" href="../../../css/index.css">
</head>

<body>
    <div id="app" class="minWidth">
        <el-form :model="form" ref="contract" :rules="rules" inline-message="true" style="width: 100%">
            <div class="table_titel">
                <div class="titel">生效时间</div>
            </div>
            <el-descriptions :column="3" border size="small">
                <!-- <el-descriptions-item label="是否长期">
                    <el-form-item prop="Type_Date">
                        <el-select style="width: 100%;" placeholder="请选择商品" filterable v-model.trim="form.Type_Date" >
                            <el-option label="短期" value="0"></el-option>
                            <el-option label="长期" value="1"></el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item> -->
                <el-descriptions-item label="开始时间">
                    <el-form-item prop="Start_Date">
                      <el-date-picker style="width: 100%;" v-model.trim="form.Start_Date" type="datetime" placeholder="请选择开始时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item label="结算时间">
                    <el-form-item prop="End_Date">
                      <el-date-picker style="width: 100%;" :disabled="form.Type_Date=='1'" v-model.trim="form.End_Date" type="datetime" placeholder="请选择结算时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                    </el-form-item>
                </el-descriptions-item>
            </el-descriptions>
            <div class="table_titel">
                <div class="titel">适用商品</div>
                <div class="operation">
                    <el-button type="primary" size="small" @click="add_sales_article_inventory">新增</el-button>
                    <el-button type="danger" size="small" @click="remove_sales_article_inventory">删除</el-button>
                </div>
            </div>
            <el-descriptions :column="3" border size="small" v-for="(item,index) in form.Children.sales_article_inventory" :key="index">
                <el-descriptions-item label="适用商品">
                    <el-form-item prop="Article_SerialNumber">
                        <el-select style="width: 100%;" placeholder="请选择商品" filterable v-model.trim="item.Article_SerialNumber" >
                            <el-option v-for="(ite,index) in article" :key="index" :label="ite.Article_Name" :value="ite.Article_SerialNumber"></el-option>
                        </el-select>
                    </el-form-item>
                </el-descriptions-item>
                <el-descriptions-item label="库存数量">
                    <el-form-item prop="Distribute">
                        <el-input style="width: 100%;" v-model.trim="item.Distribute" placeholder="请输入库存数量"></el-input>
                    </el-form-item>
                </el-descriptions-item>
                <!-- <el-descriptions-item :label="form.Config_Type=='0'?'分销比例':'分销金额'">
                    <el-form-item prop="Config_Count">
                        <el-input style="width: 100%;" v-model.trim="form.Config_Count" placeholder="请输入方案金额"></el-input>
                    </el-form-item>
                </el-descriptions-item> -->
            </el-descriptions>
            <el-form-item class="form-operation">
                <el-button @click="window.history.back()">返回</el-button>
                <el-button type="success" @click="()=>{this.dialogVisible = true}">导入</el-button>
                <el-button type="primary" :loading="loading" @click="submitForm('contract')">提交</el-button>
            </el-form-item>
        </el-form>
        <el-dialog :visible.sync="dialogVisible">
          <img width="100%" :src="dialogImageUrl" alt="">
        </el-dialog>
        <el-dialog title="导入表格" fullscreen="true" :visible.sync="dialogVisible">
          <el-select @change="handleDate" placeholder="请选择商品" filterable
              v-model.trim="form.Type_Date">
              <el-option label="短期" value="0"></el-option>
              <el-option label="长期" value="1"></el-option>
          </el-select>
          <el-date-picker v-model.trim="form.Start_Date" type="datetime" placeholder="请选择开始时间"
              value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
          <el-date-picker v-model.trim="form.End_Date" type="datetime" placeholder="请选择结束时间"
              value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
          <div style="height: 50px;">
              <el-upload id="Excel" class="upload-demo" action="" :before-remove="beforeRemove" :file-list="fileList"
                  :before-upload="uploadDetails">
                  <el-button size="small" type="primary" v-show="fileList.length<1">导入</el-button>
                  <span slot="tip" class="el-upload__tip" v-show="fileList.length<1">请上传xlsx表格</span>
              </el-upload>
          </div>
          <div style="margin-bottom: 20px;">
              <el-table :data="tableData" stripe border height="calc(85vh - 140px)" style="width: 100%">
                  <el-table-column label="序号" width="50" type="index"></el-table-column>
                  <el-table-column prop="Article_SerialNumber" label="商品id">
                    <template v-slot="{row}">
                      {{row.Article_SerialNumber.replace('-'+$.cookie('enterprise'),'')}}
                    </template>
                  </el-table-column>
                  <el-table-column prop="Article_Name" label="商品名称"></el-table-column>
                  <el-table-column prop="Distribute" label="库存数量"></el-table-column>
              </el-table>
          </div>
          <div style="display: flex; justify-content: center; width: 100%;">
              <el-button  @click="download" type="success">下载模板</el-button>
              <el-button type="primary" :loading="loading" @click="submit">提交</el-button>
          </div>
      </el-dialog>
    </div>
    <script type="text/javascript" src="../../../js/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="../../../js/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../js/vue.min.js"></script>
    <script type="text/javascript" src="../../../elementUI/index.js"></script>
    <script type="text/javascript" src="../../../js/utils.js"></script>
    <script type="text/javascript" src="../../../js/ID_Validity.js"></script>
    <script type="text/javascript" src="../../../js/FileSaver.min.js"></script>
    <script type="text/javascript" src="../../../js/FileSaver.js"></script>
    <script type="text/javascript" src="../../../js/xlsx.full.min.js"></script>
    <script type="text/javascript" src="./js/Add.js"></script>
</body>

</html>